package q704_search;

public class Solution {
    /*
    标准的二分
     */
    public int search(int[] nums, int target) {
        int l = 0, r = nums.length - 1;
        while (r >= l) {
            int mid = l + (r - l)/2;
            if (nums[mid] == target) {
                return mid;
            }else if (nums[mid] > target) {
                r = mid - 1;
            }else {
                l = mid + 1;
            }
        }

        return  -1;
    }
}
